package com.clayecloud.common.admin.services.Impl;

import com.clayecloud.common.admin.services.ProcessTackingService;
import com.clayecloud.common.entity.House;
import com.clayecloud.common.entity.ProcessTacking;
import com.clayecloud.common.mappers.ProcessTackingMapper;
import com.clayecloud.common.utils.MessageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("AdminProcessTackingServiceImpl")
public class ProcessTackingServiceImpl implements ProcessTackingService {

    @Resource
    private ProcessTackingMapper processTackingMapper;

    @Override
    public MessageUtil insertSelective(ProcessTacking record) {
        return processTackingMapper.insertSelective(record) > 0 ? MessageUtil.success("增加成功") : MessageUtil.fail("增加失败，请联系系统管理员");
    }

    @Override
    public MessageUtil deleteByPrimaryKey(Long processId) {
        return processTackingMapper.deleteByPrimaryKey(processId) > 0 ? MessageUtil.success("删除成功") : MessageUtil.fail("增加失败，请联系系统管理员");
    }

    @Override
    public MessageUtil updateByPrimaryKeySelective(ProcessTacking record) {
        return processTackingMapper.updateByPrimaryKeySelective(record) > 0 ? MessageUtil.success("更新成功") : MessageUtil.fail("增加失败，请联系系统管理员");
    }

    @Override
    public MessageUtil<List<ProcessTacking>> selectBytrackIdAndType(Long trackId, Integer trackType) {
        return MessageUtil.success("查询成功").add(processTackingMapper.selectBytrackIdAndType(trackId, trackType));
    }

//    @Override
//    public MessageUtil<List<ProcessTacking>> selectAll(Integer size, Integer page) {
//        PageHelper.startPage(page,size);
//        List<ProcessTacking> processTackings = processTackingMapper.selectAll();
//        PageInfo pageInfo = new PageInfo(processTackings);
//        Map result = new HashMap();
//        result.put("list",processTackings);
//        result.put("total",pageInfo.getTotal());
//        return MessageUtil.success("查询成功").add(result);
//    }
}
